package com.aftersale.demo.entity;

import com.aftersale.demo.utils.ValidGroup;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.validation.annotation.Validated;

import javax.validation.Valid;
import javax.validation.constraints.*;
import java.io.Serializable;

/**
*@Author  空
*@Date    2023/10/23 20:16
*@Desc
*/
@TableName(value ="user")
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "com.aftersale.demo.entity.User",description = "用户信息")
public class User implements Serializable {
    /**
     * 主键
     */
    @TableId(type = IdType.AUTO)
    @ApiModelProperty(value = "主键")
    private Integer id;

    /**
     * 用户名
     */
    @ApiModelProperty(value = "用户名")
    @NotBlank(message = "用户名不能为空",groups = {ValidGroup.UserName.class})
    @Size(max = 20,min = 0,message = "用户名长度不能超过20位",groups = {ValidGroup.UserName.class})
    private String userName;

    /**
     * 用户密码
     */
    @NotBlank(message = "密码不能为空",groups = {ValidGroup.PassWord.class})
    @Size(max = 80,min = 0,message = "密码过长",groups = {ValidGroup.PassWord.class})
    @ApiModelProperty(value = "密码")
    private String password;

    /**
     * 真实姓名
     */
    @Size(max = 20,min = 0,message = "请输入正确的姓名",groups = {ValidGroup.RealName.class})
    @ApiModelProperty(value = "真实姓名")
    private String realName;

    /**
     * 邮箱
     */
    @ApiModelProperty(value = "邮箱")
    @NotBlank(message = "邮箱地址不能为空",groups = {ValidGroup.Email.class})
    @Email(message = "请输入正确的邮箱地址",groups = {ValidGroup.Email.class})
    private String email;

    /**
     * 角色id
     */
    @ApiModelProperty(value = "角色id；1为管理员，2售后人员，3客户，4游客")
    private Integer roleId;

    @TableField(exist = false)
    private String roleName;
    @TableField(exist = false)
    @ApiModelProperty(value = "验证码")
    @NotBlank(message = "验证码不能为空",groups = {ValidGroup.VerifyCode.class})
    @Size(max = 20,min = 0,message = "验证码错误",groups = {ValidGroup.VerifyCode.class})
    private String verifyCode;

    @TableField(exist = false)
    @ApiModelProperty(value = "原密码")
    @NotBlank(message = "原密码不能为空",groups = {ValidGroup.OldPassWord.class})
    @Size(max = 80,min = 0,message = "原密码过长",groups = {ValidGroup.OldPassWord.class})
    private String oldPassword;

    @ApiModelProperty(value = "用户提醒")
    private Boolean remind;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    public User(String userName) {
        this.userName = userName;
    }
}